import json
import sys
from pathlib import Path

base_path = str(Path(__file__).resolve().parent.parent)
sys.path.append(base_path)
from ai_configs import defalut_ai_config
from main import ai_chat_stream, default_on_receiving

_plans = [
    {"name": "入门型套餐", "cpu": 2, "memory": 2, "net": 4, "year": 1, "price": 99},
    {
        "name": "基础型套餐",
        "cpu": 2,
        "memory": 4,
        "net": 5,
        "year": 1,
        "price": 168,
    },
    {
        "name": "经济型套餐",
        "cpu": 2,
        "memory": 4,
        "net": 6,
        "year": 1,
        "price": 199,
    },
    {
        "name": "增强型套餐",
        "cpu": 4,
        "memory": 8,
        "net": 12,
        "year": 1,
        "price": 435,
    },
    {
        "name": "轻量型套餐",
        "cpu": 2,
        "memory": 2,
        "net": 4,
        "year": 3,
        "price": 368,
    },
    {
        "name": "豪华型套餐",
        "cpu": 2,
        "memory": 4,
        "net": 6,
        "year": 3,
        "price": 495,
        "gpu": 16,
    },
]

_system_prompt = f"""
# 角色
你是一名专业的云服务器销售客服

# 任务
你需要按照用户的提问，将匹配用户需求的云服务器套餐告诉用户

# 上下文
如下是目前的云服务器套餐数据

{json.dumps(_plans,ensure_ascii=False)}

套餐数据格式说明如下所示:

name: 套餐名称
cpu: 套餐的cpu核心数量
memory: 套餐的内存大小 
net: 套餐的网络带宽大小
year: 套餐的有效时长
price: 套餐价格
gpu: 显存大小

# 注意
你必须从已有的云服务器套餐中，选择一个来推荐给用户，没有完全符合的则给出一个最接近用户需求的套餐，如果连相近的套餐也没有则回复用户没有套餐能够满足用户的需求
"""

_user_content_01 = "给我来个土豪套餐"
_user_content_02 = "给我来个最贵的套餐"
_user_content_03 = "给我来个穷鬼套餐"
_user_content_04 = "给我来个企业级套餐"

_user_content = _user_content_04

ai_chat_stream(
    ai_config=defalut_ai_config["doubao"],
    on_receiving=default_on_receiving,
    histories=[
        {"role": "system", "content": _system_prompt},
        {"role": "user", "content": _user_content},
    ],
)
